package io.sdph.userprofile;

import io.sdph.userprofile.dao.UserManagerDAO;
import io.sdph.userprofile.model.User;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.context.annotation.ScopedProxyMode;
import org.springframework.stereotype.Component;

/**
 * Sessyjny menager zarządzający sesją użytkownika.
 * 
 * @author 
 * @since 0.0.1
 */
@Component
//@Scope(proxyMode=ScopedProxyMode.INTERFACES,value="session")
public class SessionManager implements ISessionManager {

	/**
	 * Zalogowany użytkownik.
	 */
	private User user;
	
	@Autowired
	UserManagerDAO manager;
	
	@Override
	public boolean logIn(String login, String password) {
		user = manager.logIn(login, password);
		return user != null;
	}

	@Override
	public boolean logOut() {
		user = null;
		return true;
	}

	@Override
	public User getCurrentUser() {
		return user;
	}

}
